﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CRM.Models.TrainingsRequestsExt>" %>
<%@ Import Namespace="CRM.Models" %>
<%@ Import Namespace="CRM.Resourses" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Редактирование заявки на вебинар
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>Редактирование заявки на вебинар</h2>

<% using (Html.BeginForm("TrainingsWebinarRequestEdit"))
       { %>
       <%: Html.ValidationSummary(true) %>
    <%:Html.Hidden("Request.IdTrainingsRequest")%>
    <%:Html.Hidden("Request.IdCustomer")%>
    <%:Html.Hidden("Request.IdTrainingsRequestsStatus")%>
    <%:Html.Hidden("Request.RequestDate")%>
    <%:Html.Hidden("Request.IdTrainingsSchedule")%>
    <%:Html.Hidden("Key")%>

    <%--<%:Html.DevExpress().Label(
              settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Выбранное расписание";
                      settings.Width = 500;
                  }).GetHtml() %>
    <%:Html.DevExpress().ComboBox( settings =>
        {
            settings.Name = "IdTrainingsSchedule";
            settings.Width = 500;
            settings.SelectedIndex = 0;
            settings.Properties.DropDownWidth = 500;
            settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
            settings.Properties.TextFormatString = "{0} {1} {2} {3}";
            settings.Properties.ValueField = "IdTrainingsSchedule";
            settings.Properties.ValueType = typeof(int);
            settings.Properties.DataSource = DB.GetTrainingsSchedulesByCourseType(3).OrderByDescending(p=>p.PlannedDate);
            settings.Properties.DataSourceID = "IdTrainingsSchedule";
            settings.Properties.Columns.Add("PlannedDate", Resourses.TrainingsPlannedDate);
            settings.Properties.Columns.Add("RubricName", "Рубрика");
            settings.Properties.Columns.Add("CourseName", "Название курса");
            settings.Properties.Columns.Add("CityName", "Город");
        }).BindList(DB.GetTrainingsSchedulesByCourseType(3).OrderByDescending(p=>p.PlannedDate)).Bind(Model.IdTrainingsSchedule).GetHtml()%>--%>


<table>
        <%--<tr>
            <td>
                <%
                   if(!(Model.IdLegalEntity > 0))
                   {
                       Html.DevExpress().Label(settings =>
                        {
                            settings.ControlStyle.CssClass = "lable";
                            settings.Text = "Введенное юр. лицо не распознано:";
                            settings.Width = 232;
                        }).GetHtml(); 
                   }
                    %>
            </td>
                
            <td>
                <%
                    if (!(Model.IdLegalEntity > 0))
                    {
                        Html.DevExpress().TextBox(settings =>
                        {
                            settings.Name = "Request.Company";
                            settings.Width = 232;
                            settings.ReadOnly = true;
                            //settings.Properties.NullText = "Введите название юр. лица...";
                        }).Bind(Model.Company).GetHtml();
                    }
                %>
            </td>
        </tr>--%>
        <tr>
            <td>
                <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Название юр. лица";
                      settings.Width = 232;
                  }).GetHtml() %>
                <%: Html.Partial("TrainingsRequestLEPartial", Model)%>
                <%--<%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Выберите юр. лицо ";
                      settings.Width = 232;
                  }).GetHtml() %>

                <% 
                    //if (Model.Request.IdLegalEntity > 0)
                    if (true)
                    {
                        Html.DevExpress().ComboBox(settings =>
                        {
                            settings.Name = "IdLegalEntity";
                            settings.ControlStyle.CssClass = "editor";
                            settings.Properties.TextField = "Name";
                            settings.Properties.ValueField = "IdLegalEntity";
                            settings.Properties.ValueType = typeof (int);
                            settings.Width = 232;
                        }).BindList(DB.GetCustomerById((int)Model.IdCustomer).LegalEntities).Bind(Model.IdLegalEntity).GetHtml();
                    }else
                    {
                        Html.DevExpress().TextBox(settings =>
                        {
                            settings.Name = "Company";
                            settings.Width = 232;
                            settings.Properties.NullText = "Введите название юр. лица...";
                        }).GetHtml();
                    }
                %>--%>
            </td>
            <td>
                <%--<%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Контактное лицо";
                      settings.Width = 232;
                  }).GetHtml() %>
    
                <% 
                    if (Model.IdContact > 0)
                    {
                        Html.DevExpress().ComboBox(settings =>
                        {
                            settings.Name = "IdContact";
                            settings.ControlStyle.CssClass = "editor";
                            settings.Properties.TextField = "Name";
                            settings.Properties.ValueField = "IdContact";
                            settings.Properties.ValueType = typeof (int);
                            settings.Width = 232;
                        }).BindList(DB.GetCustomerById((int)Model.IdCustomer).Contacts).Bind(Model.IdContact).GetHtml();
                    }else
                    {
                        Html.DevExpress().TextBox(settings =>
                        {
                            settings.Name = "ContactName";
                            settings.Width = 232;
                            settings.Properties.NullText = "Введите имя контактного лица...";
                        }).Bind(Model.ContactName).GetHtml();
                    }
                %>--%>
            </td>
        </tr>
        <tr>
            <td>
                <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Контакты";
                      settings.Width = 232;
                  }).GetHtml() %>
                <%: Html.Partial("TrainingsRequestContactPartial", Model)%>
                <%--<%:Html.DevExpress().Label(settings =>
                    {
                        settings.ControlStyle.CssClass = "lable";
                        settings.Text = "Контактный телефон";
                        settings.Width = 232;
                    }).GetHtml() %>
                <%:Html.DevExpress().TextBox( settings => 
                    {
                        settings.Name = "ContactPhone";
                        settings.Width = 232;
                        settings.Properties.MaskSettings.Mask = "+7 (999) 000-00-00";
                        settings.Properties.MaskSettings.IncludeLiterals = MaskIncludeLiteralsMode.None;
                    }).GetHtml()%>--%>
            </td>
            <td>
                <%--<%:Html.DevExpress().Label(settings =>
                    {
                        settings.ControlStyle.CssClass = "lable";
                        settings.Text = "Адрес электронной почты";
                        settings.Width = 232;
                    }).GetHtml() %>
                <%:Html.DevExpress().TextBox( settings => 
                    {
                        settings.Name = "ContactEmail";
                        settings.Width = 232;
                        settings.Properties.NullText = "Введите адрес почты";
                    }).GetHtml()%>--%>
            </td>
        </tr>
        <tr>
            <td>
                <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Статус";
                      settings.Width = 500;
                  }).GetHtml() %>
                  <%:Html.DevExpress().ComboBox(settings =>
                    {
                        settings.Name = "Request.IdTrainingsRequestsStatus";
                        settings.Properties.ValueType = typeof (int);
                        settings.Properties.TextField = "NameRu";
                        settings.Properties.ValueField = "IdTrainingRequestsStatus";
                        settings.Width = 500;
                        settings.Properties.EnableCallbackMode = true;
                    }).BindList(DB.TrainingRequestsStatuses).Bind(Model.Request.IdTrainingsRequestsStatus).GetHtml()%>
            </td>
        </tr>
    </table>


    <%--    <br />
    <%:Html.DevExpress().Label(
              settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Название компании";
                      settings.Width = 500;
                  }).GetHtml() %>
    <%:Html.DevExpress().TextBox( settings => 
                    {
                        settings.Name = "Company";
                        settings.Width = 500;
                        settings.ReadOnly = true;
                        settings.Properties.NullText = "Введите название компании...";
                    }).Bind(Model.Company).GetHtml()%>

    <br />
    <%:Html.DevExpress().Label(
              settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Контактное лицо";
                      settings.Width = 500;
                  }).GetHtml() %>
    <%:Html.DevExpress().TextBox( settings => 
                    {
                        settings.Name = "ContactName";
                        settings.Width = 500;
                        settings.Properties.NullText = "Введите имя контактного лица...";
                    }).Bind(Model.ContactName).GetHtml()%>

    <br />
    <%:Html.DevExpress().Label(
              settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Контактный телефон";
                      settings.Width = 500;
                  }).GetHtml() %>
    <%:Html.DevExpress().TextBox( settings => 
                    {
                        settings.Name = "ContactPhone";
                        settings.Width = 500;
                        settings.Properties.MaskSettings.Mask = "+7 (999) 000-00-00";
                        settings.Properties.MaskSettings.IncludeLiterals = MaskIncludeLiteralsMode.None;
                    }).Bind(Model.ContactPhone).GetHtml()%>

    <br />
    <%:Html.DevExpress().Label(
              settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Адрес электронной почты";
                      settings.Width = 500;
                  }).GetHtml() %>
    <%:Html.DevExpress().TextBox( settings => 
                    {
                        settings.Name = "ContactEmail";
                        settings.Width = 500;
                        settings.Properties.NullText = "Введите адрес электронной почты";
                    }).Bind(Model.ContactEmail).GetHtml()%>
--%>
    <br />
    <%:Html.DevExpress().Label(
              settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Комментарий";
                      settings.Width = 500;
                  }).GetHtml() %>
    <%:Html.DevExpress().TextBox( settings => 
                    {
                        settings.Name = "Request.Comments";
                        settings.Width = 500;
                        settings.Properties.NullText = "Комментарии...";
                    }).Bind(Model.Request.Comments).GetHtml()%>

    <br /><button type="submit" value="Создать заявку">Сохранить заявку</button>
    <% } %>

</asp:Content>
